#include "spinbox.h"
#include "ui_spinbox.h"

SpinBox::SpinBox(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::SpinBox)
{
    ui->setupUi(this);
}

SpinBox::~SpinBox()
{
    delete ui;
}



QString SpinBox::prefix() const {
    return ui->spinBox->prefix();
}

void SpinBox::setPrefix(const QString &prefix){
    ui->spinBox->setPrefix(prefix);
}

QString SpinBox::suffix() const {
    return ui->spinBox->suffix();
}

void SpinBox::setSuffix(const QString &suffix) {
    ui->spinBox->setSuffix(suffix);
}

QString SpinBox::cleanText() const {
    return ui->spinBox->cleanText();
}

int SpinBox::singleStep() const {
    return ui->spinBox->singleStep();
}

void SpinBox::setSingleStep(int val) {
    ui->spinBox->setSingleStep(val);
}

int SpinBox::minimum() const {
    return ui->spinBox->minimum();
}

void SpinBox::setMinimum(int min) {
    ui->spinBox->setMinimum(min);
}

int SpinBox::maximum() const {
    return ui->spinBox->maximum();
}

void SpinBox::setMaximum(int max) {
    ui->spinBox->setMaximum(max);
}

void SpinBox::setRange(int min, int max) {
    ui->spinBox->setRange(min, max);
}

int SpinBox::value() const {
    return ui->spinBox->value();
}

void SpinBox::setValue(int value) {
    ui->spinBox->setValue(value);
}

void SpinBox::on_addButton_clicked() {
    int val = ui->spinBox->value() + ui->spinBox->singleStep();
    int maxVal = ui->spinBox->maximum();
    val = val <= maxVal ? val : maxVal;
    ui->spinBox->setValue(val);
}

void SpinBox::on_subButton_clicked() {
    int val = ui->spinBox->value() - ui->spinBox->singleStep();
    int minVal = ui->spinBox->minimum();
    val = val >= minVal ? val : minVal;
    ui->spinBox->setValue(val);
}

void SpinBox::on_spinBox_textChanged(const QString &arg1) {
    emit textChanged(arg1);
}

void SpinBox::on_spinBox_valueChanged(int arg1) {
    emit valueChanged(arg1);
}
